#!/bin/bash

# 卸载所有 rsh 相关包（兼容 dnf/yum/apt）
if command -v dnf >/dev/null 2>&1; then
    dnf remove -y $(rpm -qa | grep '^rsh') 2>/dev/null
elif command -v yum >/dev/null 2>&1; then
    yum remove -y $(rpm -qa | grep '^rsh') 2>/dev/null
elif command -v apt-get >/dev/null 2>&1; then
    apt-get remove -y rsh-client rsh-server 2>/dev/null
fi

# 验证
if rpm -qa 2>/dev/null | grep -q '^rsh' || dpkg -l 2>/dev/null | grep -qE 'rsh-client|rsh-server'; then
    echo "[-] rsh 相关包仍然存在"
    exit 1
else
    echo "[+] rsh 相关包已卸载"
    exit 0
fi
